import 'package:flutter/material.dart';

class Girdtwo extends StatelessWidget {
  const Girdtwo({super.key});

  @override
  Widget build(BuildContext context) {
    return GridView.builder(
      gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
        crossAxisCount: 3,
        //子组件间距
        mainAxisSpacing: 10,
        //子组件间距
        crossAxisSpacing: 10,
        //宽高比
        childAspectRatio: 0.8,
      ),
      itemBuilder: (context, index) {
        return Container(color: Colors.red);
      },
    );
  }
}

// class Girdtwo extends StatelessWidget {
//   const Girdtwo({super.key});

//   @override
//   Widget build(BuildContext context) {
//     return GridView.extent(
//         maxCrossAxisExtent: 150,
//         //子组件间距
//         mainAxisSpacing: 10,
//         //子组件间距
//         crossAxisSpacing: 10,
//         //宽高比
//         childAspectRatio: 0.8,
//         children: List.generate(9, (index) => generator(index)));
//   }
// }

// Widget generator(index) {
//   return Container(color: Colors.primaries[index]);
// }
